package com.wzz.dao.impl;

import com.wzz.dao.SchoolDao;
import com.wzz.util.DBUtil;
import com.wzz.entity.School;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class SchoolDaoImplement implements SchoolDao {


    @Override
    public void printSchool(String name) {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        School school = null;
        try {
            con = DBUtil.getConnection();
            String sql = "select * from school where name = ?";
            ps = con.prepareStatement(sql);
            ps.setString(1,name);
            rs = ps.executeQuery();
            while(rs.next()){
                school = new School();
                school.setName(rs.getString("name"));

            }
        } catch (SQLException e){
            e.printStackTrace();
        } finally {
            try {
                DBUtil.closeConnection(con,ps,rs);
            } catch (SQLException e){
                e.printStackTrace();
            }
        }
        System.out.println("学校名称：" + school.getName());
    }
}
